package com.hfzy.ihk.web.ivr.constant;

import com.hfzy.ihk.common.support.redis.IdGenerator;
import com.hfzy.ihk.common.util.string.StringUtil;
import com.hfzy.ihk.common.util.uuid.base64uuid.UUIDs;

/**
 * Created by Administrator on 2016/6/14.
 *
 * @author wws
 *
 * redis key 前缀
 */
public class RedisKey {

    //=======================key前缀===============================

    /**经纪人用手机拨打主显号，转接到客户，达到呼出功能。
     * ---前缀----
     * <callOutUseCallIn：+主显号码+:+经纪人号码,<呼出时需要保存的字段,值>
     * 获取使用后,5分钟过期
     * */
    public static String CALL_OUT_USE_CALL_IN_PRIX = "callOutUseCallIn:";

    public static String CALL_HISTORY_RPIX = "callHistory:";

    /**************用于呼入**************start*********************************/
    /**记录最后一个通过某主显号码打给客户号码的经纪人ID等信息：
     * <newCallHistoryLastByShowNum：主显号码,<客户电话：userId，经纪人ID>>
     * <newCallHistoryLastByShowNum：主显号码,<客户电话：dataId，置业云呼记录id>>
     * <newCallHistoryLastByShowNum：主显号码,<客户电话：popupWindowId，电弹屏信息json>>
     * 改变为====>>
     * <LastCallInfo：主显号码：客户电话，<userId,经纪人ID>>
     * <LastCallInfo：主显号码：客户电话，<dataId,置业云呼记录id>>
     * <LastCallInfo：主显号码：客户电话，<popupWindowId,电弹屏信息json>>
     */
    public static String CALL_HISTORY_LAST_BY_SHOW_NUM_RPIX = "fscall:callHistoryLastByShowNum:";

    public static String PUSH_TO_ES_FAILED_HISTORY = "fscall:pushToESFailedHistory";

    /**
     * 推送录音链接数据到Es的set,此set保存sessionId和url
     */
    public static String  PUSH_URL_TO_ES_SET="fscall:pushUrlToEsSet";

    public static String INTERRUPT_FAIL = "fscall:interruptFail";

    /**
     *推送数据到Oracle失败的set
     */
    public static String PUSH_RECORD_TO_ORACLE_FAILED_SET = "fscall:pushRecordToOracleFailedSet";

    @Deprecated//
    public static String NEW_CALL_HISTORY_LAST_BY_SHOW_NUM_RPIX = "fscall:newCallHistoryLastByShowNum:";//改用LastCallInfo
    public static String LAST_CALL_INFO_RPIX = "LastCallInfo:";

    public static String LAST_CALL_INFO_USER_ID = "userId";

    public static String LAST_CALL_INFO_DATA_ID = "dataId";

    public static String LAST_CALL_INFO_CITY_ID = "cityId";

    public static String POPUP_WINDOW_ID = "popupWindowId";//保存来电弹屏信息

    public static String createLastCallInfo(String showNum, String customerPhone){
        return StringUtil.strConnect(LAST_CALL_INFO_RPIX, showNum,":",customerPhone);
    }

    public static String createFsLastCallInfo(String customerPhone){
        return StringUtil.strConnect(LAST_CALL_INFO_RPIX, customerPhone);
    }

    public static String createSessionId(){
        return UUIDs.base64UUID()+"_"+ IdGenerator.generate(RedisKey.SESSION_ID_SEQ).toString();
    }

    /** 经纪是否占线 如果先打客户，则客户接听开始就算经纪占线 <userBuzy, <经纪人ID, true/false>> **/
    public static String USER_BUSY = "userBusy";

    /**
     *号码归属地
     *只记录了广州的手机号码段，查找不到的，则表示属于异地号码
     * <phoneLocation:+手机前7位, <<city, 城市>, <province, 省份>>>
     */
    public static String PHONE_LOCATION = "phoneLocation:";

    //缓存当天客户电话被拨打次数hash
    public static String CUSTOMER_CALL_PHONE_COUNT = "customerCallPhoneCount";

    /**
     * 记录提交成功的通话id和时间：<commitSuccessSessionIdAndTime:web-200-4x,<sessionId,time>>
     * 如果插入数库成功，将删除该sessionId记录
     *  CheckAndSaveCallHistoryJob 没隔一段时间扫描该hash，为了扫描的速度，每个服务器对应一个key
     *
     * 详细看 com.hfzy.ihk.cloud.web.call.job.CheckAndSaveCallHistoryJob
     * */
    public static String COMMIT_SUCCESS_SESSIONID_AND_TIME = "commitSuccessSessionIdAndTime:"+PublicConfig.SERVER_NAME;

    /**sessionId序列
     * */
    public static String SESSION_ID_SEQ = "sessionIdSequeue";

    //默认城市
    public static String DEFAULT_CITY = "广州";
    //默认公司
    public static String DEFAULT_COMPANY = "HFZY";//

    public static String SWX_CHANNEL_QUEUE = ":swxChannelQueue";

    public static String SWX_CHANNEL_MAP = ":swxChannelMap";

    public static String TODAY_CALL_COUT = "todayCallOut";

    //阿里语音分析
    public static final String ALIBABA_ASR = "fscall:alibabaAsr";

    /**投诉我们的客户号码，这类号码不允许再呼出
     * Set
     * 直接设置到redis中
     * */
    public static String BAD_CUSTOMER_PHONE_Map = "badCustomerPhoneMap";

    //客户说话key
    public static String CUSTOMER_SPEAK_STATE = ":customer";
    //机器人播放录音key
    public static String ROBOT_SPEAK_STATE = ":robot";

    public static String IDENTIFICATION_END_STATE = "identificationEndState";

    //主显号相关
    public static String CUCC_SHOW_NUM_INDEX = "copShowNumIndex:";

    public static String CUCC_SHOW_NUM_LIST = "copShowNumList:";



}
